Component({
  properties: {
    show: { type: Boolean, value: false },
    typeValue: { type: String, value: '' },
    incomeCategoryList: { type: Array, value: [] },
    expenseCategoryList: { type: Array, value: [] },
    selectedIndex: { type: Number, value: -1 }
  },
  methods: {
    onSelect(e) {
      const { index } = e.currentTarget.dataset;
      const type = e.currentTarget.dataset.type;
      
      let list, item;
      if (type === 'income') {
        list = this.data.incomeCategoryList;
        item = list[index];
      } else if (type === 'expense') {
        list = this.data.expenseCategoryList;
        item = list[index];
      }
      
      this.triggerEvent('select', { index, type, item });
    },
    onCancel() {
      this.triggerEvent('cancel');
    }
  }
}); 